﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<skags.Models.ForumViewModel>>" %>


<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Spjallið
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div id="main">
    <h1>Spjallið</h1>
<% foreach (var t in Model) { %>
    
    <% if ((t.Category.Title != ("Stjórnendaspjall")) || (HttpContext.Current.User.IsInRole("Admin"))) { %>

<br />    
<div class="forumCategory">
    <a href="Forum/Category/<%=t.Category.ID%>"><%: t.Category.Title %></a>
                        <span> - Fimm nýjustu - </span>  
    <a href="Forum/Category/<%=t.Category.ID%>"> Sjá alla </a>
</div>    
    <table class="forum">
        <tr>
            <th width="4%"><a href="/Forum/CreateThread/<%=t.Category.ID%>"><img src="../../Content/icons/create.png" alt="Nýr þráður" /></a></th>
            <th width="24%">
                Titill
            </th>
            <th width="20%">
                Höfundur
            </th>
            <th width="16%">
                Dags
            </th>
            
            <th width="36%">
                Innihald
            </th>
        </tr>
        
        <% foreach (var thread in t.Threads) { %> 
           
        <tr>
            <td>
            <% if ((HttpContext.Current.User.Identity.Name == thread.UserName) || (HttpContext.Current.User.IsInRole("Admin"))) {%>
            
                <a href="/Forum/DeleteThread/<%=thread.ID%>" onclick="return confirm('Ertu viss um að þú viljir eyða þessum þráð?')"><img src="../../Content/icons/delete.png" alt="Eyða" /></a>
                <a href="/Forum/Edit/<%=thread.ID%>"><img src="../../Content/icons/edit.png" alt="Breyta" /></a>
                
            <% }%>
                    
            </td>
            <td>
                <%:Html.ActionLink( thread.Title, "Thread", new {id = thread.ID})%> 
            </td>
            <td>
                <p class="news_author"><a href="/Profile/User/<%=thread.AuthorIntID%>"><%=thread.UserName%></a></p>
            </td>
            <td>
                <%:String.Format("{0:g}", thread.DateCreated)%>
            </td>
            
            <td>
                <%= thread.ThreadText %>
            </td>
        </tr>

    
    <% } %>
    <% } %>
    </table>
    <% } %>
        
    

    
</div>
</asp:Content>

